package com.smartmedical.patient.video.controller;

import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.patient.video.domain.vo.PatientVideoCommentVo;
import com.smartmedical.patient.video.domain.vo.PatientVodeoVo;
import com.smartmedical.patient.video.service.VodeoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongsProject: smart-medical
 * @BelongsPackage: com.smartmedical.patient.video.controller
 * @ClassName: VodeoController
 * @Author: zyn
 * @CreateTime: 2024-01-14  15:49
 * @Description: TODO
 */
@RestController
@RequestMapping("/video")
public class PatientVodeoController {



    @Autowired
    private VodeoService vodeoService;



    /**
     * 查询视频分类列表
     *
     * @return 返回查询结果，包括视频分类列表和状态信息
     */
    @GetMapping("v1/findVideoCategoryList")
    public HealthR<List<PatientVodeoVo>> findVideoCategoryList() {



        return HealthR.ok(vodeoService.findVideoCategoryList().getResult(), "查询成功");

    }


    /**
     * 添加视频评论
     *
     * @param videoId 视频ID
     * @param content 评论内容
     * @return 返回一个HealthR对象，表示操作结果
     */
    @PostMapping("v1/addVideoComment")
    public HealthR addVideoComment(@RequestParam int videoId,@RequestParam String content) {

        vodeoService.addVideoComment(videoId, content);

        return HealthR.ok("", "评论成功");

    }


    /**
     * 添加用户视频收藏
     *
     * @param videoId 视频ID
     * @return HealthR 对象，表示请求结果，其中ok表示请求成功，message表示操作结果信息
     */
    @PostMapping("v1/addUserVideoCollection")
    public HealthR addUserVideoCollection(@RequestParam Integer videoId) {



        vodeoService.addUserVideoCollection(videoId);

        return HealthR.ok("", "收藏成功");

    }


    @PostMapping("v1/videoBuy")
    public HealthR videoBuy(@RequestParam Integer videoId, @RequestParam Integer price) {


        vodeoService.videoBuy(videoId, price);

        return HealthR.ok("", "购买成功");
    }


    @GetMapping("v1/findVideoCommentList")
    public HealthR<PatientVideoCommentVo> findVideoCommentList(@RequestParam Integer videoId) {

        HealthR<PatientVideoCommentVo> videoCommentList = vodeoService.findVideoCommentList(videoId);

        PatientVideoCommentVo result = videoCommentList.getResult();


        return HealthR.ok(result, "查询成功");
    }













}
